<section class="content-header">
 <h1>修改URI映射</h1>
</section>
<section class="content">
 <!-- /.row -->
 <div class="row">
  <div class="col-xs-12">
   <div class="box box-primary">
     <div class="box-body">
      <div class="form-group">
       <label>原始请求URI</label>
       <input type="text" class="form-control" name="request_uri" placeholder="原始请求URI">
      </div>
      <div class="form-group">
       <label>后端服务URI</label>
       <input type="text" class="form-control" name="original_uri" placeholder="后端服务URI">
      </div>
      <div class="form-group">
       <label>针对URI限流统计周期（秒），0为不限流</label>
       <input type="number" class="form-control" name="uri_limit_seconds" value="0" placeholder="针对URI限流统计周期（秒）">
      </div>
      <div class="form-group">
       <label>针对URI限流统计周期内最大允许请求数</label>
       <input type="number" class="form-control" name="uri_limit_times" value="0" placeholder="针对URI限流统计周期内最大允许请求数">
      </div>
      <div class="form-group">
       <label>针对URI单个IP限流统计周期（秒），0为不限流</label>
       <input type="number" class="form-control" name="ip_uri_limit_seconds" value="0" placeholder="针对URI限流统计周期（秒）">
      </div>
      <div class="form-group">
       <label>针对URI单个IP限流统计周期内最大允许请求数</label>
       <input type="number" class="form-control" name="ip_uri_limit_times" value="0" placeholder="针对URI限流统计周期内最大允许请求数">
      </div>
      <div class="form-group">
       <label >配置备注描述</label>
       <input type="text" class="form-control" name="description" placeholder="uri description">
      </div>
     </div>
     <!-- /.box-body -->
     <div class="box-footer">
      <button id="edit-api-btn" class="btn btn-primary">更新</button>
      <button class="btn btn-default" onclick="load_page('/pages/api/list.html');">取消</button>
     </div>
   </div>
   <!-- /.box -->
  </div>
 </div>
</section>
<script type="text/javascript">
      $(".content-header h1").html(domain_name+" > "+service_name+" > 修改URI映射")
      $("#edit-api-btn").click(function(){
      var params = {
          api_id:api_id,
          request_uri:$("input[name='request_uri']").val(),
          original_uri:$("input[name='original_uri']").val(),
          uri_limit_seconds:$("input[name='uri_limit_seconds']").val(),
          uri_limit_times:$("input[name='uri_limit_times']").val(),
          ip_uri_limit_seconds:$("input[name='ip_uri_limit_seconds']").val(),
          ip_uri_limit_times:$("input[name='ip_uri_limit_times']").val(),
          description:$("input[name='description']").val()
      };
        api_invoke("/api/v1/api/edit", params, function(data){
            if(data.errno == 0){
                load_page("/pages/api/list.html");
            }else{
                alert(data.msg);
            }
        });
      });
        $(function(){
          api_invoke("/api/v1/api/get", {api_id:api_id}, function(data){
            if(data.errno == 0){
                $("input[name='request_uri']").val(data.info.request_uri);
                $("input[name='original_uri']").val(data.info.original_uri);
                $("input[name='description']").val(data.info.description);
                $("input[name='uri_limit_seconds']").val(data.info.uri_limit_seconds);
                $("input[name='uri_limit_times']").val(data.info.uri_limit_times);
                $("input[name='ip_uri_limit_seconds']").val(data.info.ip_uri_limit_seconds);
                $("input[name='ip_uri_limit_times']").val(data.info.ip_uri_limit_times);
            }else{
                alert(data.msg);
            }
          });
        });
</script>